package com.ty.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ty.entity.Orders;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author txy
 * @since 2024-03-02
 */
public interface OrdersMapper extends BaseMapper<Orders> {
    @Select("select DISTINCT o.* from orders o,order_item oi,periodical_tb p  ${ew.customSqlSegment}")
    @Results({
            //因为type_id字段拿去关联外表，想要赋值给bookinfo还要再映射一次
            @Result(property = "orderId", column = "order_id"),
            @Result(property = "orderItems", column = "order_id",
                    many = @Many(select = "com.ty.mapper.OrderItemMapper.selectByOrderItemById"))
    })
    Page<Orders> selectAllOrder(Page<Orders> page, @Param(Constants.WRAPPER) Wrapper<Orders> wrapper);
}
